<?php
namespace Common\Model;
use Common\Common\Model;

class GoodsModel extends Model{
    protected $tableName = 'Goods';
    protected $tablePrimary = 'ID';

    public function goodsPage($value)
    {
        $User = M('Goods'); // 实例化User对象
        $count      = $User->where('category = $value')->count();// 查询满足要求的总记录数
        $Page       = new \Think\Page($count,2);// 实例化分页类 传入总记录数和每页显示的记录数(25)
        $show       = $Page->show();// 分页显示输出// 进行分页数据查询 注意limit方法的参数要使用Page类的属性
        $list = $User->where('category = $value')->limit($Page->firstRow.','.$Page->listRows)->select();
        return array(
            'list' => $list,
            'page' => $show,
        );
    }
    public function getFenGoods($fen){
        $result=$this->where('State=1 and Category='.$fen)->select();
        return $result;
    }
    public function getGoods($id){
        $result=$this->where('ID='.$id)->select();
        return $result;
    }
}